old.dir = '/home1/99/jc152199/MicroclimateStatisticalDownscale/250mASCII/microCLIM/'
new.dir = '/home1/99/jc152199/MAXENT/ASCII/microCLIM/'

old.files = list.files(old.dir, full.names=T)
new.names = gsub('.asc.gz','.asc',gsub('_','',basename(old.files)))

i=1

for (tfile in old.files)

	{
	
	tt = read.asc.gz(tfile)
	
	write.asc(tt, file=paste(new.dir,new.names[i],sep=''))
	
	#cat('n\',i,'n\')
	
	i=i+1
	
	}
	
# Done